<template>
	<view>
		<view class="prompt">如果下单价格不一致，客服会与您联系确认，谢谢。</view>
		<view class="order-box">
		
				
			
			<view class="order-list" v-for="(item,index) in list" :key="index">
				<view class="goods-name">{{item.goodsName}}</view>
				<view class="price-box flex flai">
					<text>价格</text>
					<input type="text" class="flex1" v-model="item.price">
				</view>
			</view>
			
		</view>
		<view style="height: 170rpx;"></view>
		<cover-view class="footer-box">
			<cover-view @click="submit" class="comfirm-btn">确认下单</cover-view>
		</cover-view>
	</view>
</template>

<script>
	import API from '../../api/index.js'
	export default {
		data() {
			return {
				list: [],
				
			}
		},
		onLoad(opt) {
			var dealData = JSON.parse(opt.data)
			var needData = []
			for (var k in dealData) {
				if (dealData[k].products.length>0) {
					var product = dealData[k].products
					for (var y in product) {
						needData.push(
							{"packId":dealData[k].packId,
							"goodsId":product[y].goodsId,
							"goodsName":product[y].goodsName,
							"price":product[y].price,
							
						})
					}
				}
			}
			console.log(needData)
			this.list = needData
		},
		methods: {
			submit() {
				API.indexHome.submitOrder(this.list).then(res => {
					if (res.errno == '0') {
						uni.showToast({
							title: '提交成功',
							duration: 2000
						});
						setTimeout(()=>{
							wx.redirectTo({
								url:'/pages/orderSubmitSucces/orderSubmitSucces'
							})
						},2000)
					}
				})
			}
		}
	}
</script>

<style>
	@import url("./index.css");
</style>
